using System;
using System.Web.Mvc;

namespace NuGet.Enterprise.Server.Controllers.ActionResults
{
    public class HttpStatusCodeResult 
        : ActionResult
    {
        public HttpStatusCodeResult(int statusCode)
            : this(statusCode, null)
        { }

        public HttpStatusCodeResult(int statusCode, string statusDescription)
        {
            StatusCode = statusCode;
            StatusDescription = statusDescription;
        }

        public override void ExecuteResult(ControllerContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            
            context.HttpContext.Response.StatusCode = this.StatusCode;
            
            if (this.StatusDescription != null)
            {
                context.HttpContext.Response.StatusDescription = this.StatusDescription;
            }
        }

        public int StatusCode
        {
            get;
            private set;
        }

        public string StatusDescription
        {
            get;
            private set;
        }
    }
}
